﻿// JavaScript Document
//回到顶部js
$(window).ready(function () {
    $(window).scroll(function () {
        var Right1 = ($(window).width() - 960) / 2 - $('.GoTop').width() - 1
        if ($(document).scrollTop() > 250) {
            $('.GoTop').show().css('right', Right1 + 'px');
        } else {
            $('.GoTop').hide();
        }
    })
    $(window).resize(function () {
        var Right2 = ($(window).width() - 960) / 2 - $('.GoTop').width() - 1
        if ($(document).scrollTop() > 250) {
            $('.GoTop').show().css('right', Right2 + 'px');
        } else {
            $('.GoTop').hide();
        }
    })
    $('.GoTop').click(function () {
        $('body,html').animate({
            scrollTop: 0
        }, 300);
        return false;
    })
})
//一次性解决单复选框浏览器bug
$(function CheckboxBug() {
    $("input:checkbox").addClass('CheckboxBug');
    $("input:radio").addClass('RadioBug');
})
function KeFuQQ() {
    var qqhtml = '<div id="qqcontent"><div class="qqfirst"></div><div class="qqbox" onclick="javascript:window.open(\'http://b.qq.com/webc.htm?new=0&amp;sid=4000180838&amp;eid=218808P8z8p8P8x8P8Q80&amp;o=www.gaitu.com&amp;q=7\', \'_blank\', \'height=544, width=644,toolbar=no,scrollbars=no,menubar=no,status=no\');"><ul><li class="time time9">9:00</li><li class="time timefuhao">~</li><li class="time time23">23:00</li><li style="cursor: pointer"title="点我在线QQ咨询"alt="点我在线QQ咨询">客服小茹</li><li style="cursor: pointer"title="点我在线QQ咨询"alt="点我在线QQ咨询">客服小麦</li><li style="cursor: pointer"title="点我在线QQ咨询"alt="点我在线QQ咨询">客服小七</li><li class="qq">QQ:4000180838</li></ul></div></div>';
    $('body').append(qqhtml);
    $(".qqfirst").hover(function () {
        $(this).hide();
        $(".qqbox").show();
    });
    $(".qqbox").hover(function () {
    }, function () {
        $(this).hide();
        $(".qqfirst").show();
    });
}
$('.card_div_left .tm').live('mousemove', function () {

    $(this).parent('li').children('div').children('a').css('border', '3px solid #f60')
})
$('.card_div_left .tm').live('mouseout', function () {
    $(this).parent('li').children('div').children('a').css('border', '3px solid #E2E2E2')
})
//批量全选
$(function () {
    $('.SelectOptions label input:checkbox').click(function () {

        if ($(this).attr("checked")) {
            $('.batc_buy input:checkbox').attr('checked', 'checked');
        } else {
            $('.batc_buy input:checkbox').attr('checked', '');
        }
    })
})
//文本框鼠标和点击后样式
$(function GaiTuText() {
    $("input:text,textarea").live('mousemove', function () {
        $(this).addClass('gt_text_hover');
    })
    $("input:text,textarea").live('mouseout', function () {
        $(this).removeClass("gt_text_hover");
    });

    $("input:text,textarea").live('focus', function () {
        $(this).addClass('gt_text_focus');
    })
    $("input:text,textarea").live('blur', function () {
        $(this).removeClass('gt_text_focus');
    })

})
//媒体报道
$(document).ready(function () {
    $(".topico").live("click", function () {
        $(".Us_Cooperation  ul").animate({
            marginTop: "-48px"
        }, 600, function () {
            $(this).css({ marginTop: "0px" }).find("li:first").appendTo(this);
        });
    });
    $(".bottomico").live("click", function () {
        $('.Us_Cooperation  ul').find("li:last").prependTo(".Us_Cooperation  ul");
        $('.Us_Cooperation  ul').css('margin-top', '-48px');
        $(".Us_Cooperation  ul").animate({
            marginTop: "12px"
        }, 600, function () {
            $(this).css({ marginTop: "0px" });
        });
    });

})
////最近使用js
$(function JustnowUsed() {
    $('.Justnow_Used').hover(function () {
        $(this).children('a').addClass('J_hover');
        $(this).children('.J_U_Tem').show();



        if (getCookie("uid") == "") { $('.J_U_Tem p').eq(1).show(); return; } else { $('.J_U_Tem p').hide(); }


        if ($('.J_U_Tem ul').html().length > 50) {
            return;
        }
        $('.J_U_Tem ul').html('<div class="no_reck" ><img src="/images/loading.gif"/>  正在努力加载···</div>')
        $.ajax({
            url: '/ajaxPage/ajaxMp.ashx',
            type: 'GET',
            data: 'ajaxType=2&pageSize=8&pageIndex=1',
            dataType: 'json',
            timeout: 60000,
            error: function () { },
            success: function (json) {
                var result_html = '';
                if (json.result.length > 0) {
                    $.each(json.result, function (key, val) {


                        result_html += '<li><a href="javascript:void(0)"><img class="' + val.shape + '" src="' + val.src + '"  alt="' + val.title + '" /></a> <span onclick="window.location=\'http://mp.gaitu.com/' + val.MpImg_ID + '.html\'" ></span>  </li>';
                    });
                    $('.J_U_Tem ul').html(result_html);
                }
                else {//无数据
                    $('.J_U_Tem p').eq(0).show();
                    $('.J_U_Tem ul').html("");
                }
            }
        });


    }, function () {
        $(this).children('a').removeClass('J_hover');
        $(this).children('.J_U_Tem').hide();
    })
})
//购买记录滚动js

$(function () {
    var interval = 3000;
    var slide = setInterval(slideIt, interval);
});
function slideIt() {
    var obj = $(".Dynamiclist li");
    obj.first().slideDown(5000);

    obj.last().insertBefore(obj.first()).hide();

    obj.last().hide().prev().hide();

    obj.last().insertBefore(obj.first()).fadeIn(1000);

    obj.eq(0).hide().slideDown(300);
};

//TAB切换
function CardListNav(obj) {
    $('.card_list_nav li a').removeClass('select');
    $(obj).addClass('select');
    $('.Card_div_HZBF').hide();
    var tab = $(obj).attr('tab');
//    alert("显示DIV"+tab);
    $('.' + tab).show();
    var pageindex = $('.' + tab + ' .pagination_ctn').attr("pageIndex");
    eval(tab + '(' + pageindex + ')');
}
//关于印刷
$(function AboutPrintInfo() {
    $('.Aboutprint_info').hover(function () {
        $('.d_S_Sign').hide();
        $(this).children('a').addClass('y_hover');
        $(this).children('.print_info_show').show();
    }, function () {
        $('.d_S_Sign').show();
        $(this).children('a').removeClass('y_hover');
        $(this).children('.print_info_show').hide();
    })
})
//LOGO列表弹出
function ShowLogoList(obj) {
    if ($('#logo_list').css('display') == 'none') {
        $('#logo_list').slideDown();

        if ($('.load_logo_list ul').html().length < 20) {
            load_logo_list(1);
        }



    } else {
        $('#logo_list').slideUp();
    }
}
//正面反面却换
function CloseLogoSelector() {
    $('#logo_list').hide();
}

function LogoNav(obj) {
    $('.logolistnav > a').removeClass('bg');
    $(obj).addClass('bg');
    $('#LogoWarehouse, #LogoRecentlyused, #LogoWellKnown').hide();
    $('#' + $(obj).attr('tabnav')).show();
    eval($('#' + $(obj).attr('tabnav')).attr('class') + "(1);");
}

function select_card_side(side) {
    if (typeof side == 'undefined') side = 'front';
    $('#card_editor_form_ctn .tab_ctn_nav ul li').removeClass('bg_hover');
    $('#card_editor_form_ctn .tab_ctn_nav ul li.' + side).addClass('bg_hover');
    CloseLogoSelector();
    //var reverse_side = side == 'front' ? 'back' : 'front';
    $('#card_ctn li').removeClass('c');
    $('#card_' + side).addClass('c');



    var objID = "";
    if ($('#card_front').hasClass('c')) {
        objID = "F";
    } else {
        objID = "B";
    }
    if ($("#" + objID + "LImg").length > 0) {
        regLogoSize($("#" + objID + "LogoImg").attr('src'), false);
        $(".logo_slider").show();
    } else {
        $(".logo_slider").hide();
    }
    $('#EditorYouIfo .form').hide();
    $('#card_form_' + side).show();
}

function del_logo(side) {


    if (side == "f") {

        if ($("#card_form_front .del_logo").html() == "隐藏LOGO") {
            $("#FLImg").css("width", "0px").css("height", "0px");
            $("#card_form_front .del_logo").html("显示LOGO");
        } else {
            $("#FLImg").css("width", $("#FLogoImg").attr("w") + "px").css("height", $("#FLogoImg").attr("h") + "px");
            $("#card_form_front .del_logo").html("隐藏LOGO");
            regLogoSize($("#FLogoImg").attr('src'), false);
        }

    } else {

        if ($("#card_form_back .del_logo").html() == "隐藏LOGO") {
            $("#BLImg").css("width", "0px").css("height", "0px");
            $("#card_form_back .del_logo").html("显示LOGO");
        } else {
            $("#BLImg").css("width", $("#BLogoImg").attr("w") + "px").css("height", $("#BLogoImg").attr("h") + "px");
            $("#card_form_back .del_logo").html("隐藏LOGO");
            regLogoSize($("#BLogoImg").attr('src'), false);
        }

    }

}

function regLogoSize(imgSrc, isNewLogo) {

    var objID = "";
    if ($('#card_front').hasClass('c')) {
        objID = "F";
    } else {
        objID = "B";
    }
    if ($("#" + objID + "LImg").length > 0) {

        var imgW = 60;
        var imgH = 60;
        // var sliderleft = $('.sliderBlock').css('left');
        var image = new Image();
        image.src = imgSrc + '?' + new Date();
        if (version < 11) {

            image.onreadystatechange = function () {
                if (image.readyState == "complete") {
                    imgW = image.width;
                    imgH = image.height;

                    var logoimgW = $("#" + objID + "LImg").css("width");
                    var logoimgH = $("#" + objID + "LImg").css("height");

                    if ($("#" + objID + "LogoImg").attr('w') == $("#" + objID + "LogoImg").attr('h') && imgW == imgH) {
                        LogoEnlarge($("#" + objID + "LogoImg").attr('w'), $("#" + objID + "LogoImg").attr('h'), "" + objID + "LImg", imgSrc, $("#" + objID + "LogoImg").attr('xx'), $("#" + objID + "LogoImg").attr('yy'));
                    } else {
                        LogoEnlarge(imgW, imgH, "" + objID + "LImg", imgSrc, $("#" + objID + "LogoImg").attr('xx'), $("#" + objID + "LogoImg").attr('yy'));
                    }

                    if (isNewLogo) {
                        $("#" + objID + "LImg").css('width', imgW + 'px').css('height', imgH + 'px');

                    } else {
                        $("#" + objID + "LImg").css('width', logoimgW).css('height', logoimgH);

                    }

                    var l_left = parseInt($("#" + objID + "LogoImg").attr('xx')) + parseInt($("#" + objID + "LogoImg").attr('w')) / 2 - parseInt($("#" + objID + "LImg").css("width").replace("px", "")) / 2;
                    var l_top = parseInt($("#" + objID + "LogoImg").attr('yy')) + parseInt($("#" + objID + "LogoImg").attr('h')) / 2 - parseInt($("#" + objID + "LImg").css("height").replace("px", "")) / 2;
                    $("#" + objID + "LImg").css('top', l_top + 'px').css('left', l_left + 'px').css('position', 'absolute');

                }
            }
        }
        else {
            image.onload = function () {
                if (image.complete == true) {
                    imgW = image.width;
                    imgH = image.height;
                    if ($("#" + objID + "LogoImg").attr('w') == $("#" + objID + "LogoImg").attr('h') && imgW == imgH) {
                        LogoEnlarge($("#" + objID + "LogoImg").attr('w'), $("#" + objID + "LogoImg").attr('h'), "" + objID + "LImg", imgSrc, $("#" + objID + "LogoImg").attr('xx'), $("#" + objID + "LogoImg").attr('yy'));
                    } else {
                        LogoEnlarge(imgW, imgH, "" + objID + "LImg", imgSrc, $("#" + objID + "LogoImg").attr('xx'), $("#" + objID + "LogoImg").attr('yy'));
                    }

                    if (isNewLogo) {
                        $("#" + objID + "LImg").css('width', imgW + 'px').css('height', imgH + 'px');
                    }
                    var l_left = parseInt($("#" + objID + "LogoImg").attr('xx')) + parseInt($("#" + objID + "LogoImg").attr('w')) / 2 - parseInt($("#" + objID + "LImg").css("width").replace("px", "")) / 2;
                    var l_top = parseInt($("#" + objID + "LogoImg").attr('yy')) + parseInt($("#" + objID + "LogoImg").attr('h')) / 2 - parseInt($("#" + objID + "LImg").css("height").replace("px", "")) / 2;
                    $("#" + objID + "LImg").css('top', l_top + 'px').css('left', l_left + 'px').css('position', 'absolute');

                }
            }
        }
        $('.logo_slider').show();
    } else {
        $('.logo_slider').hide();
    }

}

/*圆角切换*/
function SelectVora() {
    if (document.getElementById('Select_vora').checked) {

        $('#card_ctn li').addClass('round');
        //        $('#Select_vora_text').html('直角预览');
    } else {

        $('#card_ctn li').removeClass('round');
        //        $('#Select_vora_text').html('圆角预览');
    }
}

//保存下载背景切换
$(function AboutPrintInfo() {
    $('#print_card').hover(function () {
        $(this).css('background-position', '-92px -104px');
    }, function () {
        $(this).css('background-position', '0px -104px');
    })
    $('#weitiao_card').hover(function () {
        $(this).css('background-position', '-92px -34px');
    }, function () {
        $(this).css('background-position', '0px -34px');
    })
    $('#save_card').hover(function () {
        $(this).css('background-position', '-92px 1px');
    }, function () {
        $(this).css('background-position', '0px 1px');
    })
    $('#download_card').hover(function () {
        $(this).css('background-position', '-92px -69px');
    }, function () {
        $(this).css('background-position', '0px -69px');
    })
})

var text_str_f = '';
var text_str_b = '';

var ot_id_f = '';
var ot_id_b = '';

var logo_str_f = '';
var logo_str_b = '';

var text_countf = 0;
var text_countb = 0;

function setMpCookie() {


    $('#EditorYouIfo li.error input').css('border', '1px solid #f20a0a');

    var ot_ids = getCookie("ot_ids");
    var text_strs = getCookie("text_strs");

    if (ot_ids == "" || text_strs == "") {

        $(".rpttxt").each(function (key, val) {
            text_strs += encodeURIComponent($(val).val()) + '⅛';
            ot_ids += $(val).attr('ot_id') + '⅛';
        });
    } else {

        var arro = $('#hid_ot_ids').val().split('⅛');
        var arrt = $('#hid_text_strs').val().split('⅛');

        var arroc = ot_ids.split('⅛');
        var arrtc = text_strs.split('⅛');

        $(".rpttxt").each(function (key, val) {
            if ($(val).val() != arrt[key]) {
                var ot_id = $(val).attr("ot_id");
                var isHas = false;
                var j = -1;
                for (var i = 0; i < arroc.length; i++) {
                    if (arroc[i] == ot_id) {
                        j = i;
                        break;
                    }
                }
                if (j > -1) {

                    arrtc[j] = encodeURIComponent($(val).val());
                    text_strs = arrtc.join("⅛") + '⅛';

                }
                else {
                    ot_ids += $(val).attr('ot_id') + '⅛';
                    text_strs += encodeURIComponent($(val).val()) + '⅛';
                }
            }
        });

    }



    $.cookie("text_strs", null);
    $.cookie("ot_ids", null);
    $.cookie("text_strs", text_strs, { expires: 7 });
    $.cookie("ot_ids", ot_ids, { expires: 7 });
}

function getMpInfo() {

    text_str_f = '';
    text_str_b = '';

    ot_id_f = '';
    ot_id_b = '';

    logo_str_f = '';
    logo_str_b = '';

    text_countf = 0;
    text_countb = 0;


    $('#card_form_front li input').each(function (key, val) {
        text_str_f += encodeURIComponent($(val).val()) + '⅛';
        ot_id_f += $(val).attr('ot_id') + '⅛';
        text_countf++;
    });
    $('#card_form_back li input').each(function (key, val) {
        text_str_b += encodeURIComponent($(val).val()) + '⅛';
        ot_id_b += $(val).attr('ot_id') + '⅛';
        text_countb++;
    });
    if ($("#FLImg").length > 0) {
        var otherInfo = $("#FLImg").css("left").replace("px", "") + '⅛' + $("#FLImg").css("top").replace("px", "") + '⅛' + $("#FLImg").css("width").replace("px", "") + '⅛' + $("#FLImg").css("height").replace("px", "");
        if ($("#FLogoImg").attr('logo_id') == "0") {
            logo_str_f = $("#FLogoImg").attr('src') + '⅛' + otherInfo;
        } else {
            logo_str_f = $("#FLogoImg").attr('logo_id') + '⅛' + otherInfo;
        }
    }

    if ($("#BLImg").length > 0) {
        var otherInfo = $("#BLImg").css("left").replace("px", "") + '⅛' + $("#BLImg").css("top").replace("px", "") + '⅛' + $("#BLImg").css("width").replace("px", "") + '⅛' + $("#BLImg").css("height").replace("px", "");
        if ($("#BLogoImg").attr('logo_id') == "0") {
            logo_str_b = $("#BLogoImg").attr('src') + '⅛' + otherInfo;
        } else {
            logo_str_b = $("#BLogoImg").attr('logo_id') + '⅛' + otherInfo;
        }
    }
    if (text_str_f.replace(/\s+/g, "").replace(/\⅛/g, "") == "") {
        if (text_countf > 0) {
            showInfo('名片上没有填写任何内容，请重试！'); return;
        }
    }

    if (text_str_b.replace(/\s+/g, "").replace(/\⅛/g, "") == "") {
        if (text_countb > 0) {
            showInfo('名片上没有填写任何内容，请重试！'); return;
        }
    }

    //记录cookie
    $.cookie("text_strs", text_str_f + "⅛" + text_str_b, { expires: 7 }); //在更改文本时 已记录
    $.cookie("ot_ids", ot_id_f + "⅛" + ot_id_b, { expires: 7 });
    $.cookie("logo_str_f", logo_str_f, { expires: 7 });
    $.cookie("logo_str_b", logo_str_b, { expires: 7 });
}

//获取COOKIE值
function getCookie(name) {
    var re = new RegExp(name + "=([^;]+)");
    var value = re.exec(document.cookie);
    var r_str = "";
    if (value != null) {
        try {
            r_str = decodeURI(value[1]);
        } catch (e) {

        }
    }
    return r_str;
}

function saveMp() {

    if (getCookie("uid") == "") {
        express_login(saveMp);
        return;
    }
    getMpInfo();
    showLoad("正在保存,请稍后!");
    $.ajax({
        url: '/ajaxPage/ajaxMp.aspx',
        type: 'POST',
        data: 'dotype=1&MpImg_ID=' + $("#hid_MpImg_ID").val() + '&FaceText=' + text_str_f + '&BackText=' + text_str_b + '&pt_id_f=' + ot_id_f + '&pt_id_b=' + ot_id_b + '&FaceLogoInfo=' + logo_str_f + '&BackLogoInfo=' + logo_str_b + '&savetype='+$("#SaveType").val()+'&SaveName=',
        dataType: 'html',
        timeout: 60000,
        error: function () {
            showInfo("保存失败");
        },
        success: function (data) {
            if (data > 0) {
                showInfo("<p style='margin-top:-5px;font-weight:700;'>保存成功</p><p class='save_area'><a  href='javascript:void(0)' onclick='sysInfoDialog.close_dialog()'>继续设计</a><a href='javascript:void(0)' onclick='dialogDmPcard();'>下载名片</a><a href='http://mp.gaitu.com/OnlinePrint.aspx?sendtype=2&sendid=" + data + "' target='_blank'>印刷名片</a></p>");

                $('.load_save_mp_list .pagination_ctn').attr("pageIndex", "0");
                load_save_mp_list(1);


            }
            else {
                showInfo("保存失败");
            }
        }
    });

    loading_dialog.close_dialog();
}

function dialogDmPcard() {
    sysInfoDialog.close_dialog();
    downMp();
}

//添加保存类型
//function AddmpSaveType() {

//    if ($("#txtSaveType").val() == "") {
//        $(".XinZen_Yan").html("*不能为空");
//        return;
//    } else {

//    }

//    $.post("/ajaxPage/ajaxMp.ashx", { ajaxType: 12, typeName: $("#txtSaveType").val() }, function (data) {
//        if (data == "1") {
//            $('.sltSaveType').append('<option checked="checked">' + $("#txtSaveType").val() + '</option>');
//            $(".sltSaveType").val($("#txtSaveType").val());
//        }
//        else {
//            showInfo("添加失败");
//        }
//    });
//}


//获取名片保存分类列表
//function getmpSaveTypeList() {
//    $.ajax({
//        url: '/ajaxPage/ajaxMp.ashx',
//        type: 'GET',
//        data: 'ajaxType=11',
//        dataType: 'json',
//        timeout: 60000,
//        error: function () {
//        },
//        success: function (json) {
//            var result_html = '<option>行政部</option><option>财务部</option><option>人力资源部</option><option>销售部</option><option>策划部</option><option>市场部</option><option>客户服务部</option><option>公关部</option>';
//            if (json.result.length > 0) {
//                $.each(json.result, function (key, val) {
//                    result_html += '<option>' + val.typeName + '</option>';
//                });
//                $('.sltSaveType').html(result_html);
//            } else {//无数据
//                $('.sltSaveType').html(result_html);
//            }
//        }
//    });
//}

$(".go_xinzeng").live("click", function () {
    $(".TianJia").show();
});
$(".ok_SaveMp").live("click", function () {
    $(".TianJia").hide();
});
$(".txtSaveName").live("blur", function () {
    if ($(this).val() == "") {
        $(".NameYan").html("*不能为空");
        //最后一个确定禁用
    } else {
        $(".NameYan").html(" ");
        //最后一个确定解禁
    }
});

function printMp() {


    if ($("#EditorYouIfo li").hasClass("error")) {
        $("#mberror_card_box").animate({ top: '-67px' }, 800);
        setTimeout(function () { $("#mberror_card_box").show(); }, 500);
        setTimeout(function () { $("#mberror_card_box p span").html('6'); }, 1000);
        setTimeout(function () { $("#mberror_card_box p span").html('5'); }, 2000);
        setTimeout(function () { $("#mberror_card_box p span").html('4'); }, 3000);
        setTimeout(function () { $("#mberror_card_box p span").html('3'); }, 4000);
        setTimeout(function () { $("#mberror_card_box p span").html('2'); }, 5000);
        setTimeout(function () { $("#mberror_card_box p span").html('1'); }, 6000);
        setTimeout(function () { $("#mberror_card_box p span").html('0'); }, 7000);
        setTimeout(function () { $("#mberror_card_box").hide().css('top', '87px'); $("#mberror_card_box p span").html('6'); }, 8000);
        //$('#mberror_card_box').show();
        return;
    } else {
        $('#mberror_card_box').hide().css('top', '87px');
    }

    getMpInfo();
    showLoad("正在加载,请稍后!");

    $.ajax({
        url: '/ajaxPage/ajaxMp.aspx',
        type: 'POST',
        data: 'dotype=3&MpImg_ID=' + $("#hid_MpImg_ID").val() + '&FaceText=' + text_str_f + '&BackText=' + text_str_b + '&pt_id_f=' + ot_id_f + '&pt_id_b=' + ot_id_b + '&FaceLogoInfo=' + logo_str_f + '&BackLogoInfo=' + logo_str_b,
        dataType: 'html',
        timeout: 60000,
        error: function () {
            showInfo("提交失败");

        },
        success: function (data) {
            if (data != 0) {
                location.href = "/OnlinePrint.aspx?sendtype=1&sendid=" + data.split('￥')[0] + "&SCode=" + data.split('￥')[1];
            }
            else {
                showInfo("提交失败");

            }
        }
    });

    loading_dialog.close_dialog();
}

function weitiaoMp() {

    getMpInfo();
    showLoad("正在加载,请稍后!");

    $.ajax({
        url: '/ajaxPage/ajaxMp.aspx',
        type: 'POST',
        data: 'dotype=2&isdown=1&MpImg_ID=' + $("#hid_MpImg_ID").val() + '&FaceText=' + text_str_f + '&BackText=' + text_str_b + '&pt_id_f=' + ot_id_f + '&pt_id_b=' + ot_id_b + '&FaceLogoInfo=' + logo_str_f + '&BackLogoInfo=' + logo_str_b,
        dataType: 'html',
        timeout: 60000,
        error: function () {

            showInfo("操作失败");
        },
        success: function (data) {
            if (data != "0") {
                window.location.href = '/mpFlash/MpFlashDefault.aspx?saveinfoid=' + +data.split('￥')[0] + "&SCode=" + data.split('￥')[1]
            }
            else {
                showInfo("操作失败");

            }
        }
    });
    loading_dialog.close_dialog();

}

function downMp() {

//    if (getCookie("uid") == "") {
//        express_login(downMp);
//        return;
//    }
    getMpInfo();
    showLoad("正在下载,请稍后!");

    $.ajax({
        url: '/ajaxPage/ajaxMp.aspx',
        type: 'POST',
        data: 'dotype=2&MpImg_ID=' + $("#hid_MpImg_ID").val() + '&FaceText=' + text_str_f + '&BackText=' + text_str_b + '&pt_id_f=' + ot_id_f + '&pt_id_b=' + ot_id_b + '&FaceLogoInfo=' + logo_str_f + '&BackLogoInfo=' + logo_str_b,
        dataType: 'html',
        timeout: 60000,
        error: function () {

            showInfo("下载失败");
        },
        success: function (data) {
            if (data != "0") {

                var elemIF = document.createElement("iframe");
                elemIF.src = data;
                elemIF.style.display = "none";
                document.body.appendChild(elemIF);
                $('#downloadLink').html(data).attr("href", data);
                $('#download_card_box').show(); //下载弹出
            }
            else {
                showInfo("下载失败");


            }
        }
    });
    loading_dialog.close_dialog();

}

var isOSimg = false;
function txtConvert() {
    if (!isOSimg) {



        if ($('#FLImg').length > 0) {
            $('#FLImg').css('z-index', '98').css('_z-index', '-50');
        }
        if ($('#BLImg').length > 0) {
            $('#BLImg').css('z-index', '98').css('_z-index', '-50');
        }


        $("#FaceEImg").hide();
        $("#BackEImg").hide();

        //select_card_side('front');
        var j = $("#card_form_front .rpttxt").length;
        for (var i = 0; i < j; i++) {
            if (version == 6) {
                setTimeout("getTxtImg('F',  " + (i + 1) + ")", (i + 1) * 1000);
            } else {
                getTxtImg('F', i + 1);
            }
        }

        var k = $("#card_form_back .rpttxt").length;
        //        $('#card_ctn li').removeClass('c');
        //        $('#card_back').addClass('c');
        //select_card_side('back');
        for (var i = 0; i < k; i++) {
            if (version == 6) {
                setTimeout("getTxtImg('B', " + (i + 1) + ")", (i + 1 + j) * 1000);
            } else {
                getTxtImg('B', i + 1);
            }
        }

        // regLogoSize($("#BLogoImg").attr('src'), false);
        isOSimg = true;
        //select_card_side('front');
    }
}



function getBase64(objID, index) {

    var base64Str = $("#hid_base64").val();
    if (base64Str != '') {

        var imglist = new Array();
        if (objID == "F") {
            imglist = base64Str.split('¼')[0].split('⅛');
        }
        else {
            imglist = base64Str.split('¼')[1].split('⅛');
        }


        return 'data:image/png;base64,' + imglist[index - 1];

    } else {
        return "";
    }


}


function getTxtImg(objID, index) {
    var obj = $("#" + objID + '_txt_' + index);

    if ($("#EditorYouIfo li").hasClass("error")) {
    } else {
        $('.dchushuix,.ico2012523').hide();
    }

    $(obj).css('border', '1px solid #ddd');
    var textval = $(obj).val();
    if (textval == "") {
        textval = " "
    }
    var align = parseInt($(obj).attr("Justify"));
    var y = parseInt($(obj).attr('y'));
    var x = parseInt($(obj).attr('x'));

    var imgsrc = 'http://mp.gaitu.com/ajaxPage/getImg.aspx?ajaxType=7&align=' + align + '&context=' + encodeURIComponent(textval) + '&info=' + encodeURIComponent($(obj).attr("info"));
	
	//modify by ly 2013年1月18日10:49:26
	var imgsrc = '?action=card&method=image&align=' + align + '&context=' + encodeURIComponent(textval) + '&info=' + encodeURIComponent($(obj).attr("info"));


    //   var objID = side;
    //    if ($('#card_front').hasClass('c')) {
    //        objID = "F";
    //    } else {
    //        objID = "B";
    //    }
    if (!isOSimg) {
        if (version != 6 && mpsave_id == 0) {
            var newimgsrc = getBase64(objID, index);
            if (newimgsrc != '') {
                imgsrc = newimgsrc;
            }
        }

    }

    if (align == 1) {
        var image = new Image();

        image.src = imgsrc;

        if (version < 11) {

            image.onreadystatechange = function () {
                if (image.readyState == "complete") {

                    $("#" + objID + "Img" + index).css('top', y + 'px').css('left', (x - image.width) + 'px').css('z-index', '99');
                    if ((x - (image.width + 10)) < 0) {
                        //$("#hid_isBleed").val("1");
                        //   $(obj).parent().addClass("error").attr("title", "内容超出切割边界，请调整");
                        $('.dchushuix,.ico2012523').show();
                        $("#hid_isBleed").val("1");
                        $(obj).parent().addClass("error").attr("title", "内容超出切割边界，请调整");

                    } else {
                        $(obj).parent().removeClass("error").attr("title", "");
                    }

                }
            }

        }
        else {
            image.onload = function () {
                if (image.complete == true) {

                    $("#" + objID + "Img" + index).css('top', y + 'px').css('left', (x - image.width) + 'px').css('z-index', '99');
                    if ((x - (image.width + 10)) < 0) {
                        $('.dchushuix,.ico2012523').show();
                        $("#hid_isBleed").val("1");
                        $(obj).parent().addClass("error").attr("title", "内容超出切割边界，请调整");

                    } else {
                        $(obj).parent().removeClass("error").attr("title", "");
                    }
                }
            }
        }
    }
    else if (align == 2) {
        var image = new Image();
        image.src = imgsrc;
        if (version < 11) {
            image.onreadystatechange = function () {
                if (image.readyState == "complete") {

                    $("#" + objID + "Img" + index).css('top', y + 'px').css('left', (x - image.width / 2) + 'px').css('z-index', '99');

                    if ((x - ((image.width / 2) + 10)) < 0) {

                        $("#hid_isBleed").val("1");
                        $(obj).parent().addClass("error").attr("title", "内容超出切割边界，请调整");
                        $('.dchushuix,.ico2012523').show();

                    }
                    else {
                        if ($("#card_ctn").hasClass("horizontal")) {
                            if ((x + ((image.width / 2) + 10)) > 400) {
                                $("#hid_isBleed").val("1");
                                $(obj).parent().addClass("error").attr("title", "内容超出切割边界，请调整");
                                $('.dchushuix,.ico2012523').show();

                            } else {
                                $(obj).parent().removeClass("error").attr("title", "");
                            }
                        } else {
                            if ((x + ((image.width / 2) + 10)) > 240) {

                                $("#hid_isBleed").val("1");
                                $(obj).parent().addClass("error").attr("title", "内容超出切割边界，请调整");
                                $('.dchushuix,.ico2012523').show();

                            } else {
                                $(obj).parent().removeClass("error").attr("title", "");
                            }
                        }

                    }
                }
            }
        }
        else {
            image.onload = function () {
                if (image.complete == true) {
                    $("#" + objID + "Img" + index).css('top', y + 'px').css('left', (x - image.width / 2) + 'px').css('z-index', '99');

                    if ((x - ((image.width / 2) + 10)) < 0) {

                        $("#hid_isBleed").val("1");
                        $(obj).parent().addClass("error").attr("title", "内容超出切割边界，请调整");

                        $('.dchushuix,.ico2012523').show();

                    }
                    else {
                        if ($("#card_ctn").hasClass("horizontal")) {
                            if ((x + ((image.width / 2) + 10)) > 400) {

                                $("#hid_isBleed").val("1");
                                $(obj).parent().addClass("error").attr("title", "内容超出切割边界，请调整");
                                $('.dchushuix,.ico2012523').show();

                            }
                            else {
                                $(obj).parent().removeClass("error").attr("title", "");
                            }
                        } else {
                            if ((x + ((image.width / 2) + 10)) > 240) {
                                $("#hid_isBleed").val("1");
                                $(obj).parent().addClass("error").attr("title", "内容超出切割边界，请调整");
                                $('.dchushuix,.ico2012523').show();

                            } else {
                                $(obj).parent().removeClass("error").attr("title", "");
                            }
                        }

                    }

                }
            }
        }

    }
    else {
        var image = new Image();
        image.src = imgsrc;
        if (version < 11) {
            image.onreadystatechange = function () {
                if (image.readyState == "complete") {
                    if ($("#card_ctn").hasClass("horizontal")) {
                        if ((x + (image.width + 10)) > 400) {
                            $("#hid_isBleed").val("1");
                            $(obj).parent().addClass("error").attr("title", "内容超出切割边界，请调整");
                            $('.dchushuix,.ico2012523').show();

                        }
                        else {
                            $(obj).parent().removeClass("error").attr("title", "");
                        }
                    } else {
                        if ((x + (image.width + 10)) > 240) {
                            $("#hid_isBleed").val("1");
                            $(obj).parent().addClass("error").attr("title", "内容超出切割边界，请调整");

                            $('.dchushuix,.ico2012523').show();

                        }
                        else {
                            $(obj).parent().removeClass("error").attr("title", "");
                        }
                    }
                }
            }
        }
        else {
            image.onload = function () {
                if (image.complete == true) {

                    if ($("#card_ctn").hasClass("horizontal")) {
                        if ((x + (image.width + 10)) > 400) {
                            $("#hid_isBleed").val("1");
                            $(obj).parent().addClass("error").attr("title", "内容超出切割边界，请调整");
                            $('.dchushuix,.ico2012523').show();

                        }
                        else {
                            $(obj).parent().removeClass("error").attr("title", "");
                        }
                    } else {
                        if ((x + (image.width + 10)) > 240) {
                            $("#hid_isBleed").val("1");
                            $(obj).parent().addClass("error").attr("title", "内容超出切割边界，请调整");
                            $('.dchushuix,.ico2012523').show();

                        }
                        else {
                            $(obj).parent().removeClass("error").attr("title", "");
                        }
                    }
                }
            }
        }


        $("#" + objID + "Img" + index).css('top', y + 'px').css('left', x + 'px').css('z-index', '99');
    }

    $("#" + objID + "Img" + index).attr('src', imgsrc).css('border', '0');

    //    $("#FaceEImg").hide();
    //    $("#BackEImg").hide();
    setMpCookie();

}

function select_logo(obj) {
    var findattr = '';

    var objID = "";
    if ($('#card_front').hasClass('c')) {
        objID = "F";
    } else {
        objID = "B";
    }
    var imgsrc = $(obj).find('img').attr('src');
    $("#" + objID + "LogoImg").attr('logo_id', $(obj).attr('logo_id')).attr('src', imgsrc).css('border', '0');
    regLogoSize(imgsrc, true);
    $("#" + objID + "LImg").attr('src', imgsrc);
}

function load_his_logo_list() {


    if (getCookie("uid") == "") {
        express_login(load_his_logo_list);
        return;
    }
    if ($('.load_his_logo_list ul').html().length > 20) {
        return;
    }
    $.ajax({
        url: '/ajaxPage/ajaxMp.ashx',
        type: 'GET',
        data: 'ajaxType=8',
        dataType: 'json',
        timeout: 60000,
        error: function () { },
        success: function (json) {
            var result_html = '';
            if (json.result.length > 0) {
                $.each(json.result, function (key, val) {
                    result_html += '<li><a href="javascript:void(0)" onclick="select_logo(this);" logo_id="' + val.MpLogo_ID + '"><img src="' + val.src + '" width="50" height="50" alt="logo"><span class="tm"></span></a></li>';
                });
                $('.load_his_logo_list ul').html(result_html);
            }
            else {//无数据
            }
        }
    });
}

function load_service_assurance() { }

function load_company_logo_list(pageIndex) {

    if (parseInt($('.load_company_logo_list .pagination_ctn').attr("pageIndex")) == parseInt(pageIndex)) {

        if ($('.load_company_logo_list ul').html().length > 20) {
            return;
        }
    }

    if (pageIndex == 0) {
        pageIndex = 1;
    }
    $.ajax({
        url: '/ajaxPage/ajaxMp.ashx',
        type: 'GET',
        data: 'ajaxType=7&pageSize=20&pageIndex=' + pageIndex,
        dataType: 'json',
        timeout: 60000,
        error: function () {

        },
        success: function (json) {
            var result_html = '';
            if (json.result.length > 0) {
                $.each(json.result, function (key, val) {
                    result_html += '<li><a href="javascript:void(0)" onclick="select_logo(this);" logo_id="' + val.MpLogo_ID + '"><img src="' + val.src + '" width="50" height="50" alt="' + val.title + '"><span class="tm"></span></a></li>';
                });
                $('.load_company_logo_list ul').html(result_html);
                if (json.pagination.page_count > 1) {
                    $('.load_company_logo_list .pagination_ctn').html(paginator(json.pagination, "load_company_logo_list({pageIndex})", 2));
                    $('.load_company_logo_list .pagination_ctn').show();
                } else {
                    $('.load_company_logo_list .pagination_ctn').hide();
                }
                $('.load_company_logo_list .pagination_ctn').attr("pageIndex", pageIndex);

            }
            else {//无数据
                $('.load_company_logo_list .pagination_ctn').hide();
            }
        }
    });
}

function load_logo_list(pageIndex) {

    if (parseInt($('.load_logo_list .pagination_ctn').attr("pageIndex")) == parseInt(pageIndex)) {

        if ($('.load_logo_list ul').html().length > 20) {
            return;
        }
    }
    if (pageIndex == 0) {
        pageIndex = 1;
    }
    $.ajax({
        url: '/ajaxPage/ajaxMp.ashx',
        type: 'GET',
        data: 'ajaxType=6&pageSize=20&pageIndex=' + pageIndex,
        dataType: 'json',
        timeout: 60000,
        error: function () {

        },
        success: function (json) {
            var result_html = '';
            if (json.result.length > 0) {
                $.each(json.result, function (key, val) {
                    result_html += '<li><a href="javascript:void(0)" onclick="select_logo(this);" logo_id="' + val.MpLogo_ID + '"><img src="' + val.src + '" width="50" height="50" alt="' + val.title + '"><span class="tm"></span></a></li>';
                });
                $('.load_logo_list ul').html(result_html);
                if (json.pagination.page_count > 1) {
                    $('.load_logo_list .pagination_ctn').html(paginator(json.pagination, "load_logo_list({pageIndex})", 2));
                    $('.load_logo_list .pagination_ctn').show();
                } else {
                    $('.load_logo_list .pagination_ctn').hide();
                }
                $('.load_logo_list .pagination_ctn').attr("pageIndex", pageIndex);

            }
            else {//无数据
                $('.load_logo_list .pagination_ctn').hide();
            }
        }
    });


}

function load_hot_mp_list(pageIndex) {
    var comlock = false;
    var result_htmlbf = $('.load_hot_mp_list .card_div_left ul').html();
    if (parseInt($('.load_hot_mp_list .pagination_ctn').attr("pageIndex")) == parseInt(pageIndex)) {

        if ($('.load_hot_mp_list .card_div_left ul').html().length > 10) {
            return;
        }
    }
    $('.load_hot_mp_list .card_div_left ul').html('<div class="no_reck" ><img src="/images/loading.gif"/>  正在努力加载···</div>')
    $.ajax({
        url: '/ajaxPage/ajaxMp.ashx',
        type: 'GET',
        data: 'ajaxType=1&pageSize=16&pageIndex=' + pageIndex,
        dataType: 'json',
        timeout: 60000,
        error: function () {
        },
        success: function (json) {
            var result_html = '';
            if (json.result.length > 0) {
                $.each(json.result, function (key, val) {
                    if (val.error != null) {
                        comlock = true;
                        $('.pagenyanzheng').html(val.error);
                        $('.load_hot_mp_list .card_div_left ul').html(result_htmlbf);
                        return false;

                    }
                    else {

                        result_html += '<li><span class="tm" onclick="window.location=\'http://mp.gaitu.com/' + val.MpImg_ID + '.html\'"></span><div><a href="http://mp.gaitu.com/' + val.MpImg_ID + '.html"><img src="' + val.src + '" alt="' + val.title + '"/></a></div><p><a href="http://mp.gaitu.com/' + val.MpImg_ID + '.html">' + val.title + '</a></p></li>';
                        result_htmlbf = result_html;
                    }
                });

                if (!comlock) {
                    $('.load_hot_mp_list .card_div_left ul').html(result_html);
                    if (json.pagination.page_count > 1) {
                        $('.load_hot_mp_list .pagination_ctn').html(paginator(json.pagination, "load_hot_mp_list({pageIndex})", 5));
                        $('.load_hot_mp_list .pagination_ctn').show();
                    } else {
                        $('.load_hot_mp_list .pagination_ctn').hide();
                    }
                     $('.load_hot_mp_list .pagination_ctn').attr("pageIndex", pageIndex);
                }

            }
            else {//无数据                
                $('.load_hot_mp_list .pagination_ctn').hide();
                $('.load_hot_mp_list .card_div_left ul').html('<div class="no_reck" >暂无数据 </div>')
            }
        }
    });
}

//专业版保存的

function load_zysave_mp_list(pageIndex) {

    if (getCookie("uid") == "") {
        // express_login();
        $('.load_zysave_mp_list .SignInaberfore').show();
        return;
    } else {
        $('.load_zysave_mp_list .SignInaberfore').hide();

    }

    if (typeof pageIndex == 'undefined') pageIndex = 1;
    if (parseInt($('.load_zysave_mp_list .pagination_ctn').attr("pageIndex")) == parseInt(pageIndex)) {

        if ($('.load_zysave_mp_list .card_div_left ul').html().length > 10) {
            return;
        }
    }
    $('.load_zysave_mp_list .card_div_left ul').html('<div class="no_reck" ><img src="/images/loading.gif"/>  正在努力加载···</div>')
    $.ajax({
        url: '/ajaxPage/ajaxMp.ashx',
        type: 'GET',
        data: 'ajaxType=16&pageSize=9&pageIndex=' + pageIndex,
        dataType: 'json',
        timeout: 60000,
        error: function () {

        },
        success: function (json) {
            var result_html = '';
            if (json.result.length > 0) {
                $.each(json.result, function (key, val) {
                    result_html += '<li><span class="tm" onclick="window.location=\'http://mp.gaitu.com/mpFlash/MpFlashDefault.aspx?saveid=' + val.SaveID + '\'"></span><div><a href="http://mp.gaitu.com/mpFlash/MpFlashDefault.aspx?saveid=' + val.SaveID + '" target="_blank"><img width="' + (val.shape == 1 ? "200" : "70") + '"  height="120"  src="' + val.src + '" alt="' + val.title + '"/></a></div><p><a href="http://mp.gaitu.com/mpFlash/MpFlashDefault.aspx?saveid=' + val.SaveID + '" target="_blank">' + val.title + '</a></p></li>';
                });
                $('.load_zysave_mp_list .card_div_left ul').html(result_html);
                if (json.pagination.page_count > 1) {
                    $('.load_zysave_mp_list .pagination_ctn').html(paginator(json.pagination, "load_zysave_mp_list({pageIndex})", 5));
                    $('.load_zysave_mp_list .pagination_ctn').show();
                } else {
                    $('.load_zysave_mp_list .pagination_ctn').hide();
                }
                $('.load_zysave_mp_list .pagination_ctn').attr("pageIndex", pageIndex);

            }
            else {//无数据
                $('.load_zysave_mp_list .card_div_left ul').html('<div class="no_reck" >暂无数据 </div>');
                $('.load_zysave_mp_list .pagination_ctn').hide();

            }
        }
    });
}


//我保存的【专业版、普通版、企业版】
function load_save_mp_list(pageIndex) {
    if (getCookie("uid") == "") {
        // express_login();
        $('.load_save_mp_list .SignInaberfore').show();
        return;
    } else {
        $('.load_save_mp_list .SignInaberfore').hide();

    }

    if (typeof pageIndex == 'undefined') pageIndex = 1;
    if (parseInt($('.load_save_mp_list .pagination_ctn').attr("pageIndex")) == parseInt(pageIndex)) {

        if ($('.load_save_mp_list .card_div_left ul').html().length > 10) {
            return;
        }
    }
    $('.load_save_mp_list .card_div_left ul').html('<div class="no_reck" ><img src="/images/loading.gif"/>  正在加载···</div>')
    $.ajax({
        url: '/ajaxPage/ajaxMp.ashx',
        type: 'GET',
        data: 'ajaxType=3&pageSize=9&pageIndex=' + pageIndex,
        dataType: 'json',
        timeout: 60000,
        error: function () {

        },
        success: function (json) {
            var result_html = '';
            if (json.result.length > 0) {
                $.each(json.result, function (key, val) {
                    var openURL = '';
                    if (val.OperType == "Z") {//专业版
                        openURL = "/mpFlash/MpFlashDefault.aspx?saveid=" + val.MpSave_ID;
                    }
                    else if (val.OperType == "Q") {//企业版
                        openURL = "/" + val.SpecialURL + '/save/' + val.MpSave_ID + '.html';
                    }
                    else {//普通版
                        openURL = "/save/" + val.MpSave_ID + ".html";
                    }
                    result_html += '<li><span class="tm" onclick="window.location=\'' + openURL + '\'"></span><div><a href="' + openURL + '"><img width="' + (val.shape == 1 ? "200" : "70") + '"  height="120"  src="' + val.src + '" alt="' + val.title + '"/></a></div><p><a href="'+openURL+'">' + val.title + '</a></p></li>';
                });
                $('.load_save_mp_list .card_div_left ul').html(result_html);
                // $('.load_save_mp_list .no_reck').hide();
                if (json.pagination.page_count > 1) {
                    $('.load_save_mp_list .pagination_ctn').html(paginator(json.pagination, "load_save_mp_list({pageIndex})", 5));
                    $('.load_save_mp_list .pagination_ctn').show();
                } else {
                    $('.load_save_mp_list .pagination_ctn').hide();
                }
                $('.load_save_mp_list .pagination_ctn').attr("pageIndex", pageIndex);

            }
            else {//无数据
                $('.load_save_mp_list .card_div_left ul').html('<div class="no_reck" >暂无数据 </div>');
                $('.load_save_mp_list .pagination_ctn').hide();
                //$('.load_save_mp_list .no_reck').show();

            }
        }
    });
}

function load_Fav_mp_list(pageIndex) {

    if (getCookie("uid") == "") {
        //express_login();
        $('.load_Fav_mp_list .SignInaberfore').show();
        return;
    } else {
        $('.load_Fav_mp_list .SignInaberfore').hide();
    }
    if (typeof pageIndex == 'undefined') pageIndex = 1;
    if (parseInt($('.load_Fav_mp_list .pagination_ctn').attr("pageIndex")) == pageIndex) {
        if ($('.load_Fav_mp_list .card_div_left ul').html().length > 10) {
            return;
        }
    }
    $('.load_Fav_mp_list .card_div_left ul').html('<div class="no_reck" ><img src="/images/loading.gif"/>  正在努力加载···</div>')
    $.ajax({
        url: '/ajaxPage/ajaxMp.ashx',
        type: 'GET',
        data: 'ajaxType=4&pageSize=9&pageIndex=' + pageIndex,
        dataType: 'json',
        timeout: 60000,
        error: function () {

        },
        success: function (json) {
            var result_html = '';
            if (json.result.length > 0) {
                $.each(json.result, function (key, val) {
                    result_html += '<li><span class="tm" onclick="window.location=\'http://mp.gaitu.com/' + val.MpImg_ID + '.html\'"></span><div><a href="http://mp.gaitu.com/' + val.MpImg_ID + '.html"><img src="' + val.src + '" alt="' + val.title + '"/></a></div><p><a href="http://mp.gaitu.com/' + val.MpImg_ID + '.html">' + val.title + '</a></p></li>';
                });
                $('.load_Fav_mp_list .card_div_left ul').html(result_html);
                // $('.load_Fav_mp_list .no_reck').hide();
                if (json.pagination.page_count > 1) {
                    $('.load_Fav_mp_list .pagination_ctn').html(paginator(json.pagination, "load_Fav_mp_list({pageIndex})", 5));
                    $('.load_Fav_mp_list .pagination_ctn').show();
                } else {
                    $('.load_Fav_mp_list .pagination_ctn').hide();
                }
                $('.load_Fav_mp_list .pagination_ctn').attr("pageIndex", pageIndex);

            }
            else {//无数据
                $('.load_Fav_mp_list .pagination_ctn').hide();
                //$('.load_Fav_mp_list .no_reck').show();
                $('.load_Fav_mp_list .card_div_left ul').html('<div class="no_reck" >暂无数据 </div>')
            }
        }
    });
}

function load_Recently_mp_list(pageIndex) {

    if (getCookie("uid") == "") {
        // express_login();
        $('.load_Recently_mp_list .SignInaberfore').show();
        return;
    } else {
        $('.load_Recently_mp_list .SignInaberfore').hide();
    }
    if (typeof pageIndex == 'undefined') pageIndex = 1;
    if (parseInt($('.load_Recently_mp_list .pagination_ctn').attr("pageIndex")) == pageIndex) {
        if ($('.load_Recently_mp_list .card_div_left ul').html().length > 10) {
            return;
        }
    }
    $('.load_Recently_mp_list .card_div_left ul').html('<div class="no_reck" ><img src="/images/loading.gif"/>  正在努力加载···</div>')
    $.ajax({
        url: '/ajaxPage/ajaxMp.ashx',
        type: 'GET',
        data: 'ajaxType=2&pageSize=9&pageIndex=' + pageIndex,
        dataType: 'json',
        timeout: 60000,
        error: function () {

        },
        success: function (json) {
            var result_html = '';
            if (json.result.length > 0) {
                $.each(json.result, function (key, val) {
                    result_html += '<li><span class="tm" onclick="window.location=\'http://mp.gaitu.com/' + val.MpImg_ID + '.html\'"></span><div><a href="http://mp.gaitu.com/' + val.MpImg_ID + '.html"><img src="' + val.src + '" alt="' + val.title + '"/></a></div><p><a href="http://mp.gaitu.com/' + val.MpImg_ID + '.html">' + val.title + '</a></p></li>';
                });
                //$('.load_Recently_mp_list .no_reck').hide();
                $('.load_Recently_mp_list .card_div_left ul').html(result_html);
                if (json.pagination.page_count > 1) {
                    $('.load_Recently_mp_list .pagination_ctn').html(paginator(json.pagination, "load_Recently_mp_list({pageIndex})", 5));
                    $('.load_Recently_mp_list .pagination_ctn').show();
                } else {
                    $('.load_Recently_mp_list .pagination_ctn').hide();
                }
                $('.load_Recently_mp_list .pagination_ctn').attr("pageIndex", pageIndex);

            }
            else {//无数据
                $('.load_Recently_mp_list .pagination_ctn').hide();
                // $('.load_Recently_mp_list .no_reck').show();
                $('.load_Recently_mp_list .card_div_left ul').html('<div class="no_reck" >暂无数据 </div>')
            }
        }
    });
}

function load_new_mp_order_list(pageIndex) {

    //$('.card_list_nav .nav06 a').attr('onclick',' ')
    if ($('.oederlist table tr').length > 2) {
        return;
    }

    $.ajax({
        url: '/ajaxPage/ajaxMp.ashx',
        type: 'GET',
        data: 'ajaxType=5&pageSize=13',
        dataType: 'json',
        timeout: 60000,
        error: function () {

        },
        success: function (json) {
            var result_html = '';
            if (json.result.length > 0) {
                $.each(json.result, function (key, val) {
                    result_html += '<tr><td>' + val.uname + '</td><td><a target="_blank" href="/' + val.MpImg_ID + '.html">' + val.title + '</a></td><td>' + val.paytime + '</td><td>' + val.BoxNum + '盒</td><td>' + val.pt + '</td></tr>';
                });
                $('.caRecent_orders .no_reck').hide();
                $('.oederlist .nav').after(result_html);

            }
            else {//无数据
                $('.caRecent_orders .no_reck').show().html('暂无数据');

            }
            // $('.card_list_nav .nav06 a').attr('onclick', 'CardListNav(this)');
        }
    });
}

function load_Review_list(pageIndex) {
    if (parseInt($('.load_Review_list .pagination_ctn').attr("pageIndex")) == pageIndex) {
        if ($('.load_Review_list ul').html().length > 10) {
            return;
        }
    }

    $.ajax({
        url: '/ajaxPage/ajaxMp.ashx',
        type: 'GET',
        data: 'ajaxType=9&pageSize=5&pageIndex=' + pageIndex,
        dataType: 'json',
        timeout: 60000,
        error: function () {

        },
        success: function (json) {
            var result_html = '';
            if (json.result.length > 0) {
                $.each(json.result, function (key, val) {
                    result_html += '<li><span><a href="http://i.gaitu.com/' + val.uid + '">' + val.userName + '</a> 于 <b>' + val.commentime + '</b> 发表评论：</span><p>' + val.ccontent + '</p></li>';
                });
                $('.load_Review_list .card_div_left ul').html(result_html);
                if (json.pagination.page_count > 1) {
                    $('.load_Review_list .pagination_ctn').html(paginator(json.pagination, "load_Review_list({pageIndex})", 5));
                    $('.load_Review_list .pagination_ctn').show();
                } else {
                    $('.load_Review_list .pagination_ctn').hide();
                }
                $('.load_Review_list .pagination_ctn').attr("pageIndex", pageIndex);

            }
            else {//无数据
                $('.load_Review_list .pagination_ctn').hide();
            }
        }
    });
}

//知名企业保存记录
function tabcontent1(pageIndex) {

    if (getCookie("uid") == "") {
        //  express_login();
        $('#tabcontent1 .SignInaberfore').show();
        $('.no_reck_cm').hide();
        return;
    } else {
        $('#tabcontent1 .SignInaberfore').hide();
    }

    $('#tabcontent1 ul').html('<div class="no_reck" ><img src="/images/loading.gif"/>  正在努力加载···</div>');
    $.ajax({
        url: '/ajaxPage/ajaxMp.ashx',
        type: 'GET',
        data: 'ajaxType=3&pageSize=9&pageIndex=' + pageIndex + '&Ent_ID=' + $('#hid_Ent_ID').val(),
        dataType: 'json',
        timeout: 60000,
        error: function () {

        },
        success: function (json) {
            var result_html = '';
            if (json.result.length > 0) {
                $.each(json.result, function (key, val) {
                    result_html += '<li><div><a href="http://mp.gaitu.com/save/' + val.MpSaving_ID + '.html"><img  width="' + (val.shape == 1 ? "200" : "70") + '"  height="120"   src="' + val.src + '" alt="' + val.title + '"/></a></div><p><a href="http://mp.gaitu.com/save/' + val.MpSaving_ID + '.html">' + val.title + '</a></p></li>';
                });
                $('#tabcontent1 ul').html(result_html);
                // $('.no_reck_cm').hide();
                if (json.pagination.page_count > 1) {
                    $('#tabcontent1 .pagination_ctn').html(paginator(json.pagination, "tabcontent1({pageIndex})", 5));
                    $('#tabcontent1 .pagination_ctn').show();

                } else {
                    $('#tabcontent1 .pagination_ctn').hide();
                }
                $('#tabcontent1 .pagination_ctn').attr("pageIndex", pageIndex);

            }
            else {//无数据
                $('#tabcontent1 .pagination_ctn').hide();
                //$('.no_reck_cm').show();
                $('#tabcontent1 ul').html('<div class="no_reck">暂无数据 </div>');

            }
        }
    });
}

function paginator(obj, func, splitnum) {
    var page_count = obj.page_count;
    var page_no = obj.page_no;
    var page_size = obj.page_size;

    var num = splitnum * 2;
    var start = 1;
    var end = splitnum * 2;
    var prev = 1;
    var next = page_no + 1;
    if (page_no > page_count) 
    page_no = page_count;
    if (page_no <= 0) 
    page_no = 1;
    if (page_no > 1) {
        prev = page_no - 1;
    }
    if (next > page_count) {
        next = page_count;
    }

    if (page_count > 1) {
        if (end > page_count)
            end = page_count;

        if (page_no + splitnum <= page_count) {
            start = page_no - (splitnum - 1);
            end = page_no + splitnum;
        }
        else {
            start = page_count - (num - 1);
            end = page_count;
        }

    }
    if (start < 1) start = 1;
    end = end > page_count ? page_count : end;
    var html = '<a href="javascript:void(0);" class="prev" onclick="' + func.replace('{pageIndex}', prev + '') + ';">上一页</a>';
    for (i = start; i <= end; i++) {
        if (i == page_no) {
            html += '<span class="c">' + i + '</span>';
        }
        else 
           html += '<a href="javascript:void(0)" onclick="' + func.replace('{pageIndex}', i + '') + ';">' + i + '</a>';
       
    }

    if (page_no == page_count) {
        html += '<a href="javascript:void(0)" class="next">下一页</a>';
    } else{
        html += '<a href="javascript:void(0)" class="next"  onclick="' + func.replace('{pageIndex}', next + '') + ';">下一页</a>';
    }

    html += "到第<input class='logoinput blue_border' onkeyup='javascript:value=value.replace(/[^0-9]/g,\"\");' onkeypress='if(event.keyCode==13){goto($(this).next());}'  />页<button ico='" + func.replace("({pageIndex})", "") + "' onclick='goto(this);' class='logobutton'>跳转</button><span class='pagenyanzheng' style='color:red; padding:0 0 0 5px;'></span>"
    return html;
}

function goto(obj) {
    eval($(obj).attr("ico") + "(" + $(obj).prev("input").val() + ")");
}

function SendReview() {

    if (retLogin()) {
        //var valicode = $('#txt_valicode').val();
        var valicode = '';
        var plycont = $('#txt_Review').val();
        var pid = 0;
        var test = plycont.replace(/( )/g, "");
        test = test.replace(/(　)/g, "");
        if (test.length <= 2) {
            showInfo('输入的内容太短!至少2个字符')
            //$('.mpCommentV').html('输入的内容太短！');
            return;
        }
        //  $('.mpCommentV').html('<img src="\images/card/loading.gif" alt="正在提交"\><span>正在提交留言···</span>');
        var post_data = 'ajaxType=13&t=' + 10 + "&id=" + 1 + "&c=" + encodeURI(plycont.replace(/(<)/g, "￥lt;")) + "&uid=" + 0 + "&pid=" + pid + "&valicode=" + valicode;
        $.ajax({
            url: '/ajaxPage/ajaxMp.ashx',
            type: 'POST',
            data: post_data,
            dataType: 'json',
            timeout: 60000,
            error: function () { showInfo('发布留言失败，请稍后重试！'); },
            success: function (json) {
                var result_html = '';
                if (json.result.length > 0) {
                    $('.load_Review_list .pagination_ctn').attr("pageIndex", 0);
                    load_Review_list(1);
                } else {
                    //无数据                   
                }

            }
        });
    }
}

//判断登录
function retLogin() {
    if (getCookie("uid") == "") {
        express_login();
        return false;
    }
    return true;
}

//添加收藏
function AddMpFavorite() {
    if (getCookie("uid") == "") {
        express_login(AddMpFavorite);
        return;
    }

    $.post("/ajaxPage/ajaxMp.ashx", { ajaxType: 14, MpImg_id: $("#hid_MpImg_ID").val() }, function (data) {
        if (data == 1) {
            var collectnum = parseInt($('#sp_collectNum').html().replace('（', '').replace('）', '')) + 1;
            $('#sp_collectNum').html('（' + collectnum + '）');
            //showInfo('收藏成功');
            $('#Plus_s_1').html('收藏成功 +1')
            $('#Plus_s_1').show(300);
            $('#Plus_s_1').fadeOut(1000);
        } else if (data == -1) {
            $('#Plus_s_1').html('您已经收藏过了')
            $('#Plus_s_1').show(300);
            $('#Plus_s_1').fadeOut(1000);
        } else {
            showInfo('收藏失败');
        }
    });

}

var isLike = false;
//顶/喜欢
function AddMpLike(obj) {
    if (!isLike) {
        $.post("/ajaxPage/ajaxMp.ashx", { ajaxType: 15, MpImg_id: $("#hid_MpImg_ID").val() }, function (data) {
            if (data == 1) {

                var likenum = parseInt($('#sp_likeNum').html().replace('（', '').replace('）', '')) + 1;
                $('#sp_likeNum').html('（' + likenum + '）');
                isLike = true;
            }
        });
        $('#Plus_one').html('+1')
        $('#Plus_one').show(300);
        $('#Plus_one').fadeOut(1000);
    } else {
        //showInfo('您已经点过了!');
        $('#Plus_one').html('不能再顶啦')
        $('#Plus_one').show(300);
        $('#Plus_one').fadeOut(1000);
    }
}

function K_load_hot_card_list(page_no) {
    $('.express_load_ctn a').addClass('ld').html('正在努力加载中...');
    var current_page_no = parseInt($('.load_hot_mp_list .pagination_ctn span').html()) + 1;

    $.ajax({
        url: '/ajaxPage/ajaxMp.ashx',
        type: 'GET',
        data: 'ajaxType=1&pageSize=16&pageIndex=' + current_page_no,
        dataType: 'json',
        timeout: 60000,
        error: function () {

        },
        success: function (json) {
            var result_html = '';
            if (json.result.length > 0) {
                $.each(json.result, function (key, val) {

                    result_html += '<li><span class="tm" onclick="window.location=\'http://mp.gaitu.com/' + val.MpImg_ID + '.html\'"></span><div><a href="http://mp.gaitu.com/' + val.MpImg_ID + '.html"><img src="' + val.src + '" alt="' + val.title + '"/></a></div><p><a href="http://mp.gaitu.com/' + val.MpImg_ID + '.html">' + val.title + '</a></p></li>';
                });
                $('.load_hot_mp_list .card_div_left ul').append(result_html);
                $('.express_load_ctn a').removeClass('ld').html(''); ;
                if (json.pagination.page_count > 1) {
                    $('.load_hot_mp_list .pagination_ctn').html(paginator(json.pagination, "load_hot_mp_list({pageIndex})", 5));
                    $('.load_hot_mp_list .pagination_ctn').show();
                } else {
                    $('.load_hot_mp_list .pagination_ctn').hide();
                }
                $('.load_hot_mp_list .pagination_ctn').attr("pageIndex", page_no);

            }
            else {//无数据
                //                    $('.load_hot_mp_list .pagination_ctn').hide();
                //                    $('.load_hot_mp_list .card_div_left ul').html('<div class="no_reck" >暂无数据 </div>')
            }
        }
    });


}

function getMpCookie() {


    var ot_ids = getCookie("ot_ids");
    var text_strs = getCookie("text_strs");
    if (ot_ids != "" && text_strs != "") {
        var arro = ot_ids.split('⅛')
        var arrt = text_strs.split('⅛')

        $(".rpttxt").each(function (j) {
            for (var i = 0; i < arro.length; i++) {
                if (arro[i] == $(this).attr("ot_id")) {
                    $(this).val(decodeURIComponent(arrt[i]));

                    arro.splice(i, 1);
                    arrt.splice(i, 1);
                    break;
                }
            }
        });
        $("#hid_base64").val('');
    }


    isOSimg = false;
    txtConvert();

}
function getMpDefault() {
    var arro = $('#hid_ot_ids').val().split('⅛');
    var arrt = $('#hid_text_strs').val().split('⅛');

    $(".rpttxt").each(function (j) {
        for (var i = 0; i < arro.length; i++) {
            if (arro[i] == $(this).attr("ot_id")) {
                $(this).val(decodeURIComponent(arrt[i]));

                arro.splice(i, 1);
                arrt.splice(i, 1);
                break;
            }
        }
    });

    isOSimg = false;
    txtConvert();
}


function Add2Entmp() {
    if (getCookie("uid") == "") {
        express_login(saveMp);
        return;
    }
    var TemplateID = $('#hid_MpImg_ID').val();
    var MpName = $('#hid_MpTitle').val();
    $.ajax({
        url: '/ajaxPage/ajaxMp.aspx',
        type: 'POST',
        data: 'dotype=11&TemplateID=' + TemplateID + '&MpName=' + MpName,
        dataType: 'json',
        timeout: 60000,
        error: function () { showInfo("服务器繁忙，请稍后再试！") },
        success: function (json) {
            var jsonstatus = json.status;
            if (jsonstatus.length > 0) {
                //-1:未开通服务； -2：模版达到了上限；-3:已经添加过该模版；-4:名片模版编号不存在； >0表示添加成功
                if (jsonstatus == -1) {
                    box3();
                } else if (jsonstatus == -2) {
                    box2();
                } else if (jsonstatus == -3) {
                    showInfo("您已经添加过该模板！");
                } else if (jsonstatus == -4) {
                    showInfo("该模板不存在！");
                } else if (jsonstatus > 0) {
                    showInfo("添加成功！")
                }
            }
            else {
                showInfo("服务器繁忙，请稍后再试！")
            }
        }
    });
}

function box4() {
    var hid_EntUrl = $('#hid_EntUrl').val();
    var box1html = '<div class="succeed_tips"><h6><strong></strong>您已经添加过该模板。</h6><a href="' + hid_EntUrl + 'show.html" taget="_blank">立即查看</a></div>';
    popWin('提示', box1html, 515, 265)
}

function box1() {
    var hid_EntUrl = $('#hid_EntUrl').val();
    var box1html = '<div class="succeed_tips"><h6><strong></strong>已成功加入至您的企业名片。</h6><a href="' + hid_EntUrl + 'show.html taget="_blank">立即查看</a></div>';
    popWin('提示', box1html, 515, 265)
}

function box2() {
    var hid_EntUrl = $('#hid_EntUrl').val();
    var box2html = '<div class="fail_tips"><p>加入失败，您最多只能拥有5个企业模板。</p><p>您可以删除一些模板后在进行操作</p><a href="' + hid_EntUrl + 'show.html" taget="_blank" class="btn02"></a></div>';
    popWin("提示", box2html, 515, 265)
}

function box3() {
    var hid_EntUrl = $('#hid_EntUrl').val();
    var box3html = '<div class="fail_tips"><p>您需要先开通企业名片服务才能使用。</p><a href="' + hid_EntUrl + 'EnterApply.html" taget="_blank" class="btn04"></a></div>';
    popWin('提示', box3html, 515, 265)
}


